package com.example.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.example.entity.Role;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * <p>
 *  Mapper 接口
 * </p>
 *
 * @author liu
 * @since 2022-02-26
 */
@Mapper
public interface RoleMapper extends BaseMapper<Role> {

    @Select("SELECT\n" +
            "r.id,\n" +
            "r.`name`,\n" +
            "r.name_zh\n" +
            "FROM\n" +
            "t_role as r\n" +
            "LEFT JOIN t_admin_role as ar on r.id = ar.rid\n" +
            "WHERE ar.admin_id = #{admin_id}")
    List<Role> getRoles(Integer adminId);
}
